/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.city.set.eia.cityblog.entities.managedbeans;

import edu.city.set.eia.cityblog.entities.RegisteredUser;

import edu.city.set.eia.cityblog.sessionbeans.RegisteredUserFacadeLocal;
import java.util.ResourceBundle;
import javax.annotation.ManagedBean;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.context.SessionScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

/**
 *
 * @author Breath
 */
@ManagedBean
@RequestScoped
public class RegisteredMemberBean {

    private static final ResourceBundle citypress = ResourceBundle.getBundle("citypress");
    
    RegisteredUser registeredUser = new RegisteredUser();
    RegisteredUser registeredUser1 = new RegisteredUser();
    @EJB RegisteredUserFacadeLocal registeredFacade1;
    @EJB RegisteredUserFacadeLocal registeredFacade;

    
    public RegisteredUser getRegisteredUser() {
        return registeredUser;
    }

    public void setRegisteredUser(RegisteredUser registeredUser) {
        this.registeredUser = registeredUser;
    }

    public void persistRegisteredUser() {
        if (registeredUser != null){
            registeredFacade.create(registeredUser);
            FacesContext.getCurrentInstance().addMessage(null,
                    new FacesMessage(FacesMessage.SEVERITY_INFO,
                    citypress.getString("update.message"), citypress.getString("update.message")));
        }
    }
    
    
    public void test(){
        registeredUser1.setEmail("");
        registeredUser1.setId(1);
        registeredUser1.setName("");
        registeredUser1.setPassword("");
        registeredUser1.setStreetName("");
        registeredUser1.setSurname("");
        registeredUser1.setUserType("student");
        registeredUser1.setUsername("");
        registeredUser1.setWebsite("");
        registeredUser1.setZip(1);
        registeredFacade1.edit(registeredUser1);
    } 
}
